import { reqCategoryList, reqGetBannerList ,reqGetFloorList} from "@/api"
const state = {
    categoryList: [],
    bannerList: [],
    floorList: []
}
const actions = {
    //解构赋值，从context中解构出commit
    async categoryList({ commit }) {
        //awwit后面表达式如果是promise，则返回该promise成功的结果值(PromiseResult)
        let result = await reqCategoryList()
        // console.log(result.data.data);
        commit("CATEGORYLIST", result.data.data)
    },
    async getBannerList({ commit }) {         
        let result = await reqGetBannerList()
        if (result.data.state === 200) {            
            commit("REQGETBANNERLIST",result.data)   
        }        
    },
    async getFloorList({commit}) {
        let result = await reqGetFloorList()
        if (result.status === 200) {
            commit("REQGETFLOORLIST",result.data)
        }
    }
}
const mutations = {
    CATEGORYLIST(state, data) {
        state.categoryList = data
    },
    REQGETBANNERLIST(state, data) {
        state.bannerList = data;
    },
    REQGETFLOORLIST(state, data) {
        state.floorList = data;
    }
}
const getters = {}
export default {
    state,
    mutations,
    actions,
    getters
}